package org.biz.config;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdScalarSerializer;

import java.io.IOException;

/**
 * @author zf
 * @ClassName PasswordSerializer
 * @date 2024/7/31 15:55
 */
public class PasswordSerializer extends StdScalarSerializer<String> {

    protected PasswordSerializer() {
        super(String.class);
    }
    @Override
    public void serialize(String s, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
        if (s != null) {
            jsonGenerator.writeString("********"); //将密码替换为星号
        }
    }
}
